<template>
  <div class="com-b">
    <h2>B组件</h2>
    <button @click="fn">B传值给A</button>
  </div>
</template>

<script>
import eventBus from "@/eventBus";
export default {
  name: "com-b",
  data() {
    return {
      msg: "B组件里的数据"
    };
  },
  methods: {
    // 传递数据给A组件
    fn() {
      eventBus.$emit("BtoA", this.msg);
    }
  }
};
</script>

<style>
</style>